/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cardamy.core.card;

import org.cardamy.core.card.attr.ICardAttribute;
import org.cardamy.core.card.attr.CardAttributeHolder;
import java.util.Iterator;
import java.util.Map.Entry;

/**
 *
 * @author Santiago
 */
public class Card implements ICard {
    
    protected CardAttributeHolder _attrHolder = new CardAttributeHolder();
    
    public Card(CardAttributeHolder attrHolder) {
        _attrHolder = attrHolder;
    }

    @Override
    public String getDescription() {
        StringBuilder sb = new StringBuilder();
        Iterator<Entry<String, ICardAttribute>> it = _attrHolder.iterator();
        while(it.hasNext()) {
            Entry<String, ICardAttribute> entry = it.next();
            ICardAttribute attr = entry.getValue();
            sb.append(attr.getKey()).append(": ").
                    append(attr.getValue().toString()).append("\n");
        }
        return sb.toString();
    }
    
    public ICardAttribute getAttr(String key) {
        return _attrHolder.getAttr(key);
    }
    
    @Override
    public String toString() {
        String value = this.getAttr("Enum").getValue().toString() + " ";
        value += getAttr("Suit").getValue().toString();
        return value;
    }
    
    
    
}
